<%@ page language="java" import="com.alibaba.fastjson.JSONObject" pageEncoding="UTF-8" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%--根据物品名称获取总价--%>
<%
    JSONObject jsonData = new JSONObject();
    RecordSet rs = new RecordSet();
    RecordSet rs1 = new RecordSet();
    String requestid = Util.null2String(request.getParameter("requestid"));
    rs.executeQuery("select id,zj,sl,wplb,wpmcll from uf_stypfftz where lcck=?",requestid);
    int counts = rs.getCounts();
    int newcount = 0;
    while (rs.next()){
        String id = Util.null2String(rs.getString("id"));
        int slsl = Util.getIntValue(rs.getString("sl"));
        String wplb = Util.null2String(rs.getString("wplb"));
        String wpmc = Util.null2String(rs.getString("wpmcll"));
        double totalPrice = 0;
        int xslsl = slsl;
        int count;
        rs1.executeQuery("select id,(sl-isnull(ylysl,0)) sysl,dj from uf_styprktz " +
                "where wpmc=? and wplb=? and (sfsc is null or sfsc=1) and (sl-isnull(ylysl,0))>0" +
                " order by rksj", wpmc,wplb);
        while (rs1.next()) {
            int sysl = Util.getIntValue(rs1.getString("sysl"));
            double dj = Util.getDoubleValue(rs1.getString("dj"));
            count = xslsl - sysl;
            if (count > 0) {
                xslsl = xslsl - sysl;
                totalPrice += sysl * dj;//100
            } else {
                totalPrice += xslsl * dj;
                break;
            }
        }
      boolean flag= rs.executeUpdate("update uf_stypfftz set zj=? where id=?",totalPrice,id);
        if(flag){
            newcount++;
        }
    }
    jsonData.put("counts",counts);
    jsonData.put("count",newcount);
    out.print( jsonData.toJSONString() );
%>






